#pragma once

#include "NFServerComm/NFServerCommon/NFIDescStore.h"
#include "NFServerComm/NFServerCommon/NFIDescTemplate.h"
#include "NFLogicCommon/NFDescStoreMacrosDefine.h"
#include "NFLogicCommon/NFDescStoreTypeDefines.h"
#include "E_Transfer.nanopb.h"
#ifndef MAX_TRANSFER_TREE_NUM
#define MAX_TRANSFER_TREE_NUM 503
#endif

struct TransferTreeTypeSkillIdTransferId
{
	TransferTreeTypeSkillIdTransferId()
	{
		if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode()) {
			CreateInit();
		}
		else {
			ResumeInit();
		}
	}
	int CreateInit()
	{
		type=0;
		skill_id=0;
		transfer_id=0;
		return 0;
	}
	int ResumeInit()
	{
		return 0;
	}
	int64_t type;
	int64_t skill_id;
	int64_t transfer_id;
	bool operator==(const TransferTreeTypeSkillIdTransferId& data) const
	{
		 return type== data.type && skill_id== data.skill_id && transfer_id== data.transfer_id;
	}
	std::string ToString() const
	{
		std::stringstream ios;
		ios << type;
		ios << ",";
		ios << skill_id;
		ios << ",";
		ios << transfer_id;
		return ios.str();
	}
};

namespace std
{
	template<>
	struct hash<TransferTreeTypeSkillIdTransferId>
	{
		size_t operator()(const TransferTreeTypeSkillIdTransferId& data) const
		{
			return NFHash::hash_combine(data.type,data.skill_id,data.transfer_id);
		}
	};
}


class TransferTreeDesc : public NFI_DESC_TEMPLATE_MACRO(TransferTreeDesc, E_TransferTree, EOT_CONST_TRANSFER_TREE_DESC_ID, MAX_TRANSFER_TREE_NUM)
public:
	TransferTreeDesc();
	virtual ~TransferTreeDesc();
	int CreateInit();
	int ResumeInit();
public:
	int Load(NFResDb *pDB) override;
	int LoadDB(NFResDb *pDB) override;
	int CheckWhenAllDataLoaded() override;
	const E_TransferTree* GetDescByTypeSkillIdTransferId(int64_t type, int64_t skillId, int64_t transferId);
private:
	NFShmHashMap<TransferTreeTypeSkillIdTransferId, uint64_t, MAX_TRANSFER_TREE_NUM> m_typeSkillIdTransferIdComIndexMap;
};
